package com.zrong.gamesdk.test.integration.thread;

import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.THttpClient;
import org.apache.thrift.transport.TTransport;

/**
 * Created with IntelliJ IDEA.
 * User: zyzcl54
 * Date: 12-7-12
 * Time: 下午16:54
 * To change this template use File | Settings | File Templates.
 */
public class CommentReplyThread implements Runnable{
    public CommentReplyThread(){}
    private CommentReply commentReply;
    private long times;
    public CommentReplyThread(CommentReply commentReply,long times){
        this.commentReply=commentReply;
        this.times=times;
    }
    private CommonReplyClient.Client createCommonReplyClient() throws Exception {
        TTransport transport = new THttpClient("http://localhost:8080/UserPartake/service/thrift/commentReply");
        TProtocol protocol = new TBinaryProtocol(transport);
        CommonReplyClient.Client client = new CommonReplyClient.Client(protocol);
        return client;
    }
    @Override
    public void run() {
        try {
            CommonReplyClient.Client client = this.createCommonReplyClient();
            for (long i = 0; i < times; i++) {
                client.saveCommentReply(commentReply);
            }
        } catch (Exception e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
    }
}
